const express = require("express");
const app = express();
app.all("/jquery", (request, response) => {
	response.setHeader("Access-Control-Allow-Origin", "*");
	response.setHeader("Access-Control-Allow-Headers", "*");
	// var text = JSON.parse(request.query);
	var text = request.query;
	var teleReg = /^\d{11}$/;
	var messageReg = /^\d{6}$/;
	var passwordReg = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@/\\.!%*#?&])[A-Za-z\d$@/\\.!%*#?&]{8,}$/;
	switch (text["type"]) {
		case "tele":
			if (teleReg.test(text["text"])) {
				response.send("0");
			} else {
				response.send("1");
			};
			break;
		case "message":
			if (messageReg.test(text["text"])) {
				response.send("0");
			} else {
				response.send("1");
			};
			break;
		case "password":
			if (passwordReg.test(text["text"])) {
				response.send("0");
			} else {
				response.send("1");
			};
			break;
		case "passwordConfirm":
			if (text["password"] == (text["text"])) {
				response.send("0");
			} else {
				response.send("1");
			};
			break;
		default:
			break;
	};
})
app.listen(8000, () => {
	console.log("服务已启动，8000端口监听中......");
})
